<template>
	<view>
		<uNavbar title="通知" ></uNavbar>

		<view class="news_box ">
			<view class="news flex_ld" v-for="(item,index) in newsList" :key="index" @click="goNextPage(item.id)">
				<view class="news_r flex_Z ">
					<view class="flex_dq">
						<text class="c3">{{item.title}}</text>
						<text class="reds" v-if="!item.is_read"></text>
					</view>
					<text>{{item.small_text}}</text>
				</view>
			</view>
		</view>
		<!-- 暂无数据 / 加载更多 -->
		<noDatas :xxxList="newsList" :status="status"></noDatas>
	</view>
</template>

<script>
	import {articleList} from "../../api/index.js";
	export default {
		data() {
			return {
				page: 1,
				size: 10,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				newsList:[]
			}
		},
		
		onShow() {
			this.initList()
		},
	
		methods: {
			// 初始化列表
			initList() {
				let data = {
					page:this.page,
					type:1,
				}
				articleList(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						let list = res.data.data;
						this.newsList = this.page == 1 ? list : this.newsList.concat(list);
						console.log(this.newsList);
						if (list.length < this.size) this.status = 'nomore';
					}
				})
			},
			goNextPage(id){
				uni.navigateTo({
					url:'/pagesMy/setting/noticeDetail?id=' + id
				})
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			console.log('下拉刷新');
			let that = this;
			setTimeout(function() {
				that.page = 1,
				that.search = '',
				that.newsList = [],
				that.initList()
			}, 800);
		},
		//触底加载
		onReachBottom() {
			console.log('触底加载');
			if (this.status != 'nomore') {
				this.page = this.page + 1
				this.initList()
			}
		}
	}
</script>
<style>
	page {
		background: #E0DDDA;
	}
</style>
<style scoped>

	.news_box{
		display: flex;
		flex-direction: column;
		width: 100%;
	}
	.news{
		width: 100%;
		margin: 20rpx 0;
		padding: 0 40rpx;
	}
	.news>image{
		width: 230rpx;
		height: 144rpx;
		border-radius: 18rpx;
	}
	.news_r{
		position: relative;
		width: 100%;
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid #CFC4B7;
	}
	.news_r>text:nth-child(1){
		text-overflow:ellipsis;
		display:-webkit-box;
		-webkit-box-orient:vertical; 
		-webkit-line-clamp:1; 
		overflow:hidden; 
		font-size: 30rpx;
		font-weight: 700;
		color: #ffffff;
	}
	.news_r>text:nth-child(2){
		font-size: 24rpx;
		color: #A6A5AF;
		text-overflow:ellipsis;
		display:-webkit-box;
		-webkit-box-orient:vertical; 
		-webkit-line-clamp:2; 
		overflow:hidden; 
		margin-top: 20rpx;
	}
	.reds{
		width: 16rpx;
		height: 16rpx;
		border-radius: 50%;
		background:#fe1b1780;
		margin-left: 10rpx;
		margin-top: -30rpx;
	}
	

</style>